/**
 * 
 */
package com.antilia.infomaresme.pages;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.Model;

import com.antilia.infomaresme.data.dataobjects.Category;

/**
 * @author Ernesto
 *
 */
public abstract class CategoryLinkPanel extends Panel {

	private static final long serialVersionUID = 1L;

	private Category category;
	
	/**
	 * @param id
	 */
	public CategoryLinkPanel(String id, Category category) {
		super(id);
		this.category = category;
		AjaxLink<Void> link = new AjaxLink<Void>("link") {
			
			private static final long serialVersionUID = 1L;

			@Override
			public void onClick(AjaxRequestTarget target) {
				CategoryLinkPanel.this.onClick(target);
			}
		};

		add(link);		
		link.add(new Label("title",new Model<String>(category.getTitle()))
		.setEscapeModelStrings(false).setRenderBodyOnly(true));
	}
	
	public abstract void onClick(AjaxRequestTarget target);

	public Category getCategory() {
		return category;
	}

	public void setCategory(Category category) {
		this.category = category;
	}

}
